<template>
    <div>
        <detail-banner :bannerImg="data.bannerImg" :sightName="data.sightName" :gallaryImgs="data.gallaryImgs"></detail-banner>
        <detail-header></detail-header>
        <detail-list :categoryList="data.categoryList"></detail-list>
        <div class="ll"></div>
    </div>
</template>
<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import axios from 'axios'
import { reactive, onMounted } from 'vue'
import { useRoute } from 'vue-router'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  setup(){
    let data = reactive({
      bannerImg: '',
      sightName: '',
      gallaryImgs: [],
      categoryList: []
    })
    let route = useRoute()
    async function getData () {
      let res = await axios.get('api/detail.json', {id: route.params.id})
        let result = res.data
        if (result.ret && result.data) {
          data.bannerImg = result.data.bannerImg
          data.sightName = result.data.sightName
          data.gallaryImgs = result.data.gallaryImgs
          data.categoryList = result.data.categoryList
        }
      }
    onMounted(()=>{
      getData()
    })
    return { data }
  }
}
</script>
<style lang="stylus" scoped>
.ll
  height 8rem
</style>
